package com.samg.learning;

import com.samg.learning.service.HelloService;
import com.samg.learning.service.impl.HelloServiceImpl;

import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.RMISocketFactory;

public class ServerMain {
    public static void main(String[] args) throws IOException, AlreadyBoundException {
        HelloService helloService = new HelloServiceImpl();
        LocateRegistry.createRegistry(8801);
//        指定通信端口
        RMISocketFactory.setSocketFactory(new CustomerSocketFactory());
        Naming.bind("rmi://localhost:8801/helloService", helloService);
        System.out.println("ServerMain provide RPC service now");
    }
}
